/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * WorkInProgressDialog.java
 *
 * Created on 9 avr. 2009, 13:20:24
 */

package modbuspal.main;

import modbuspal.toolkit.FileTools;

import javax.swing.*;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;

/**
 * a dialog that appears for lengthy operations.
 * @author nnovic
 */
public class WorkInProgressDialog
extends javax.swing.JDialog
{
    /*
    class MyLayoutManager
    implements LayoutManager        
    {
        public void addLayoutComponent(String name, Component comp) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void removeLayoutComponent(Component comp) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Dimension preferredLayoutSize(Container parent) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Dimension minimumLayoutSize(Container parent) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void layoutContainer(Container parent)
        {
            int width = parent.getWidth();
            int height = parent.getHeight();

            logoLabel.setLocation(0, 0);
            logoLabel.setSize(width, height);
            messageLabel.setLocation(5, 5);
            messageLabel.setSize(width-10, height-10);
        }
    }
*/

    /** Creates new form WorkInProgressDialog 
     * @param title Title of the dialog
     * @param message message displayed inside the dialog
     */
    public WorkInProgressDialog(String title, String message)
    {
        setModalityType(ModalityType.DOCUMENT_MODAL);
        setTitle(title);
        initComponents();
        setMessage(message);
        setIconImage(FileTools.getImage("/img/icon32.png"));

        //TODO: GUITools.align(parent, this);
    }


    public void setMessage(String message)
    {
        messageLabel.setText(message);
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        logoLabel = new javax.swing.JLabel();
        messageLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(350, 100));

        logoLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        logoLabel.setIcon(new ImageIcon(FileTools.getImage("/img/modbuspal.png"))); // NOI18N
        logoLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        getContentPane().add(logoLabel, java.awt.BorderLayout.WEST);

        messageLabel.setBackground(new java.awt.Color(255, 255, 255));
        messageLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        messageLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        messageLabel.setText("MESSAGE.");
        messageLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        messageLabel.setOpaque(true);
        getContentPane().add(messageLabel, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

 

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel logoLabel;
    private javax.swing.JLabel messageLabel;
    // End of variables declaration//GEN-END:variables

}
